package com.goldgov.code.utils;

import java.io.File;
import java.io.IOException;

import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.Version;

public class FreemarkerUtils {
	
	private static Configuration config = new Configuration(new Version(2, 3, 28));

	private FreemarkerUtils() {}
	
	public static void init(File templatePath) {
		try {
			config.setDirectoryForTemplateLoading(templatePath);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static Template getTemplate(String templateName){
		try {
			return config.getTemplate(templateName,"UTF-8");
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
}
